package com.blackcat.recode.controller;


import com.blackcat.recode.common.annotation.Log;
import com.blackcat.recode.common.result.AjaxResult;
import com.blackcat.recode.enums.BusinessType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


import com.blackcat.recode.service.ProjectService;
import com.blackcat.recode.entity.Project;

/**
 * <p> 项目信息表 前端控制器
 * @author blackcat 2024-09-10
 */
@RestController
@RequestMapping("/project")
public class ProjectController {

    @Autowired
    private ProjectService projectService;

    @GetMapping("/getAllServiceList")
    public AjaxResult getAllServiceList() {
        return projectService.getAllServiceList();
    }

    @GetMapping("/getList")
    public AjaxResult getList(Integer page, Integer size, String projectName,String projectType) {
        return projectService.getList(page,size,projectName,projectType);
    }

    @Log(title = "项目编辑", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody Project project) {
        return projectService.projectEdit(project);
    }

    @GetMapping("/getOne")
    public AjaxResult getOne(String id) {
        return AjaxResult.success(projectService.getById(id));
    }

    @Log(title = "项目删除", businessType = BusinessType.DELETE)
    @DeleteMapping("/delete")
    public AjaxResult delete(String id) {
        return projectService.remove(id);
    }

    @GetMapping("/getProjectNameList")
    public AjaxResult getProjectNameList() {
        return projectService.getProjectNameList();
    }

}
